package nz.co.album.converse;

import java.util.*;
import javax.persistence.*;

@Entity
public class User {

	private long id;
	
	private String username;
	private String passwordHash;
	
	private Date joinedDate;
	
	private Set<Account> accounts;
	private Set<Address> addresses;
	
	private Set<Message> sentMessages;
	private Set<Message> receivedMessages;
	
	public User() {
		accounts = new HashSet<Account>();
		addresses = new HashSet<Address>();
		
		sentMessages = new HashSet<Message>();
		receivedMessages = new HashSet<Message>();
	}

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPasswordHash() {
		return passwordHash;
	}

	public void setPasswordHash(String passwordHash) {
		this.passwordHash = passwordHash;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getJoinedDate() {
		return joinedDate;
	}

	public void setJoinedDate(Date joinedDate) {
		this.joinedDate = joinedDate;
	}

	@OneToMany
	public Set<Account> getAccounts() {
		return accounts;
	}

	public void setAccounts(Set<Account> accounts) {
		this.accounts = accounts;
	}

	@OneToMany
	public Set<Address> getAddresses() {
		return addresses;
	}

	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}

	@OneToMany
	public Set<Message> getSentMessages() {
		return sentMessages;
	}

	public void setSentMessages(Set<Message> sentMessages) {
		this.sentMessages = sentMessages;
	}
	
	@ManyToMany
	public Set<Message> getReceivedMessages() {
		return receivedMessages;
	}

	public void setReceivedMessages(Set<Message> receivedMessages) {
		this.receivedMessages = receivedMessages;
	}

}
